import Vue from "vue";
import Vuex from "vuex";
import config from "../config"

Vue.use(Vuex) // 使用vuex管理动态数据

export default new Vuex.Store({
    state: {
        userInfo: {},
        routerPath: "/",
    },
    // 使用示例: this.$store.getters.userInfo
    getters: {
        userInfo: state => state.userInfo,
        routerPath: state => state.routerPath,
    },
    // 使用示例：this.$store.commit("mutationName", data);
    mutations: {
        setUserInfo(state, userInfo) {
            state.userInfo = userInfo
        },
        setRouterPath(state, routerPath) {
            console.log("切换路由，routerPath=" + routerPath)
            state.routerPath = routerPath
        }
    }
})
